import React, { Component } from 'react';
// import Background from '../../background/background.jpg';
let timer1 = undefined;
 
// var sectionStyle = {
//     // width: "100%",
//     height: "675px",
//   // makesure here is String确保这里是一个字符串，以下是es6写法
//     backgroundImage: `url(${Background})` 
// };

export default class Tmp extends Component {
  constructor(props) {
    super(props);
    this.state = {secondsElapsed: 0};
  }
 
  componentDidMount() {
    this.timerStart1();   
  }
 
  componentWillUnmount() {
    clearInterval(timer1);
  }
 
  record1 = () => {
    this.setState((prevState) => ({
      secondsElapsed: prevState.secondsElapsed + 1
    }));
    console.log("timer1");
  }

  timerStart1 = () =>  {
    timer1 = setInterval(() => this.record1(), 1000);
  }
 
  timerStop1= () => {
    clearInterval(timer1);
  }
 
  render() {
    return (
      <div>
      {/* <img src="../../background/background.jpg" /> */}
        <div>
          Seconds Elapsed: {this.state.secondsElapsed}
        </div>
        <div>
          <button onClick={this.timerStart1}>timerStart1</button>
          <button onClick={this.timerStop1}>timerStop1</button>
        </div>
      </div>
    );
  }
}